/*******************************************************************************
*  file    : qloggerappender.hpp
*  created : 01.05.2013
*  author  : 
*******************************************************************************/

#ifndef QLOGGERAPPENDER_HPP
#define QLOGGERAPPENDER_HPP

#include "qloggerconf.hpp"
#include "qloggerevent.hpp"
#include <QMutex>
#include <QTextStream>

class QTextCodec;

class QLOGGER_DECL QLoggerAppender
{
    private:
        QString      _format;
        QString      _time_format;
        QLoggerLevel _level;

    protected:
        QMutex       mutex;
        QTextCodec*  _codec;

    protected:
        QLoggerAppender (const QString &format,
                         int level,
                         const QString& time_format = "yyyy.MM.dd hh:mm:ss.zzz");
        void            streamWrite (QTextStream &stream, const QLoggerEvent &event);
        virtual QString format      (const QLoggerEvent &event);

    public:
        virtual void write (const QLoggerEvent &event) = 0;
        QLoggerLevel level ();
        virtual void setCodec(QTextCodec* c);
        virtual ~QLoggerAppender(){}
};

#endif // QLOGGERAPPENDER_HPP
